function PZCalc= calculatePZ(w,X,wantedZ)
    PZCalc=zeros(1,1,9,10);
    for ii=1:9 % 9rows
        for jj=1:10
            if jj==1
                down=normcdf((X(ii,jj+1)-w.*wantedZ)./sqrt(1-w.^2),0,1);
                PZCalc(1,1,ii,jj)=1-down;
            elseif jj==10
                up=normcdf((X(ii,jj)-w.*wantedZ)./sqrt(1-w.^2),0,1);
                PZCalc(1,1,ii,jj)=up;
            else
                up=normcdf((X(ii,jj)-w.*wantedZ)./sqrt(1-w.^2),0,1);
                down=normcdf((X(ii,jj+1)-w.*wantedZ)./sqrt(1-w.^2),0,1);
                PZCalc(1,1,ii,jj)=up-down;
            end
        end
    end
end

% w=0.0163;
% %to calculate predicted transition probability conditioning on Z
% for ii=1:length(Rate_list)-1 % 9rows
%    for jj=1:10
%        if jj==1
%            down=normcdf((X(ii,jj+1)-w*Z(44,1))/(1-w^2)^.5,0,1);
%            PZ(1,1,ii,jj)=1-down;
%        elseif jj==10
%                up=normcdf((X(ii,jj)-w*Z(44,1))/(1-w^2)^.5,0,1);
%                PZ(1,1,ii,jj)=up;
%        else
%               up=normcdf((X(ii,jj)-w*Z(44,1))/(1-w^2)^.5,0,1);
%                down=normcdf((X(ii,jj+1)-w*Z(44,1))/(1-w^2)^.5,0,1);
%                PZ(1,1,ii,jj)=up-down;
%        end
%    end
% end
% xx(:,:)=PZ(1,1,:,:);
% xlswrite(filename,PZ,'PZ')